package com.gdhengdian.collection;

import com.gdhengdian.collection._interface._impl.LinkedListSet;
import com.gdhengdian.collection._interface.Set;
import com.gdhengdian.collection._interface._impl.TreeSet;

/**
 * @author HD-0078 杨炜耀
 * @date 2021-4-8 11:58
 */
public class CollectionMainTest {

    public static void main(String[] args) {
        Set<Integer> linkedListSet = new LinkedListSet<>();
        Set<Integer> treeSet = new TreeSet<>();
        int number = 0;
        for (int i = 0; i < 100; i++) {
            int count = i * i;
            linkedListSet.add(count);
            treeSet.add(count);
            if(i == 88){
                number = count;
            }
        }
        println(linkedListSet, number);
        println(treeSet, number);
    }

    private static void println(Set<Integer> set, int number){
        String simpleName = set.getClass().getSimpleName();
        System.out.println("old " + simpleName + " collection size is: " + set.size());
        System.out.println(simpleName + " collection if contains \"" + number + "\": " + set.contains(number));
        System.out.println(simpleName + " collection if isEmpty: " + set.isEmpty());
        set.remove(number);
        System.out.println("removed of new " + simpleName + " collection size is: " + set.size() + "\n");
    }
}
